package br.com.lucasddaniel.merchanmobile.dao;

/**
 * Classe de cria�ao das tabelas.
 * 
 * @author ldsm
 *
 */
public class BTEsquemaBanco {
	
	/** Define a vers�o do banco. */
	public static final int CURRENT_DATABASE_VERSION = 1;
	
	/** Nome da base da aplica��o. */
	public static final String DATA_BASE_NAME = "bluetooth_devices"; 
	
	/** Tabela de Bluetooth. */
	public static final String TABLE_NAME = "tb_bluetooth_devices"; 
	
	/** SQL de cria��o da tabela de Bluetooth */
	public static final String SQL_CREATE_TABLE;
	
	public static final String SQL_DROP_TABLE;
	
	/** 
	 * Cria��o da tabela de Bluetooth.
	 */
	public static final TableColumn TABLE_COLUMNS[] = {
		new TableColumn("nome", "TEXT NOT NULL,"),
		new TableColumn("endereco", "TEXT NOT NULL,"),
		new TableColumn("principal", "INTEGER")
	};

	/* Bloco de inicializa��o*/
	static{
		final String DROP_TABLE = "DROP TABLE IF EXIST ";
		StringBuilder builder = new StringBuilder();
		
		SQL_DROP_TABLE = builder.append(DROP_TABLE).append(TABLE_NAME).toString();
		
		builder.setLength(0);
	}
	
	static{
		final String CREATE_TABLE = "CREATE TABLE ";
		StringBuilder builder = new StringBuilder();
		
		SQL_CREATE_TABLE = builder.append(CREATE_TABLE)
										.append(TABLE_NAME)
		 							   .append("(")
									   .append(TABLE_COLUMNS[0])
									   .append(TABLE_COLUMNS[1])
									   .append(TABLE_COLUMNS[2])
									   .append(")")
									   .toString();
		builder.setLength(0);
	}
	 
	public static class TableColumn{
		String columnName;
		String columnType;
		
		public TableColumn(String name, String type) {
			this.columnName = name;
			this.columnType = type;
		}
		
		public String getColumnName() {
			return this.columnName;
		}
		
		public String toString() {
			return columnName + " " + columnType;
		}
	}
}
